//
//  SleepGroupListCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/3/3.
//

#import "SleepGroupListCell.h"

@interface SleepGroupListCell()
@property (nonatomic,strong) UIImageView * iconView;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UIImageView * arrow;
@end

@implementation SleepGroupListCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setSubViewLayout];
    }
    return self;
}
-(void)setSubViewLayout{
    
    [self setCornerRadius:10 * FMScaleX];
    
    [self addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@0);
    }];
    [self addSubview:self.arrow];
    [_arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(24 * FMScaleX, 24 * FMScaleX));
        make.right.mas_offset(-10 * FMScaleX);
        make.bottom.mas_offset(-10 * FMScaleX);
    }];
    [self addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(10 * FMScaleX);
        make.centerY.equalTo(self.arrow);
    }];
}

-(void)setInfoMdoel:(SleepGroupListModel *)infoMdoel{
    
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:infoMdoel.imageUrl]];
    self.nameLabel.text = infoMdoel.title;
    
}

-(UIImageView *)iconView{
    
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
        _iconView.contentMode = UIViewContentModeScaleAspectFill;
        [_iconView setCornerRadius:10 * FMScaleX];
    }
    return _iconView;
}
-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Regular(15);
        _nameLabel.textColor = UIColor.whiteColor;
    }
    return _nameLabel;
}
-(UIImageView *)arrow{
    
    if (!_arrow) {
        _arrow = [[UIImageView alloc]init];
        _arrow.image = [UIImage imageNamed:@"Sleep_play_player"];
    }
    return _arrow;
}
@end
